<?php 
require $this->website['path']['action'].'/admin/islogin.php';


$json = array('status'=>'error','msg'=>'error','data'=>'');

$id = fn_post('id');

if(!$id){
  $json['msg'] = '分类删除错误,分类编号不能为空';
}elseif($this->website['class']['db']->table('type')->where('upid=?',$id)->limit(1)->count()){
  $json['msg'] = '分类删除错误,被删分类不能有子分类';
}elseif(!$this->website['class']['db']->table('type')->where('id=?',$id)->limit(1)->count()){
  $json['msg'] = '分类删除错误,分类未找到,或已被删除';
}else{
  $num=$this->website['class']['db']
           ->table('type')
           ->where('id=?',$id)
           ->limit(1)
           ->delete();
  if($num>0){
    $json['status'] = 'ok';
    $json['msg']    = '分类删除成功';
    $json['data']   = $id;
  }else{
    $json['msg'] = '分类删除失败';
    // $json['data'] = $this->website['class']['db']->sql;
  }
}



echo json_encode($json);